x11: Fix handling of frame clock freezes
authorMatthias Clasen <mclasen@redhat.com>
Sun, 19 May 2019 02:53:17 +0000 (02:53 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 28 May 2019 20:25:15 +0000 (20:25 +0000)
Now that popups share the frame clock of their
parent, we have to be much more careful about
freezing the clock, since that may stop updates
for another surface.

This commit makes two changes that make the
X11 handling of the frame clock more similar
to the Wayland backend:
- Use gdk_surface_freeze_updates instead of
  gdk_surface_freeze_toplevel_updates to avoid
  affecting the frame clock
- Bail out early in before_paint/after_paint
  if the surface is frozen, to avoid affecting
  the frame clock

Together, these two make the X11 popup surface
type work without freezing updates for the toplevel.

gdk/x11/gdkdisplay-x11.c
gdk/x11/gdksurface-x11.c

index 62de7d39e9e775559a8d3d45fd80f4a0bb94cab4..60a8892c59db1da85200d0cdba3f5a2070b2adb9 100644 (file)
@@ -878,7 +878,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
             }
 
          if (toplevel)
-            gdk_surface_freeze_toplevel_updates (surface);
+            gdk_surface_freeze_updates (surface);
 
           _gdk_x11_surface_grab_check_unmap (surface, xevent->xany.serial);
         }
@@ -901,7 +901,7 @@ gdk_x11_display_translate_event (GdkEventTranslator *translator,
                                         0);
 
          if (toplevel)
-           gdk_surface_thaw_toplevel_updates (surface);
+           gdk_surface_thaw_updates (surface);
        }
 
       return_val = FALSE;
index c4887c0fbcfbe51822e7a946b0fab6955d97139f..64a1d11ccad5cfccee9f01874467ad50b23c7e32 100644 (file)
@@ -745,6 +745,9 @@ static void
 on_frame_clock_before_paint (GdkFrameClock *clock,
                              GdkSurface     *surface)
 {
+  if (surface->update_freeze_count > 0)
+    return;
+
   gdk_x11_surface_predict_presentation_time (surface);
   gdk_x11_surface_begin_frame (surface, FALSE);
 }
@@ -753,8 +756,10 @@ static void
 on_frame_clock_after_paint (GdkFrameClock *clock,
                             GdkSurface     *surface)
 {
-  gdk_x11_surface_end_frame (surface);
+  if (surface->update_freeze_count > 0)
+    return;
 
+  gdk_x11_surface_end_frame (surface);
 }
 
 static void
@@ -909,7 +914,7 @@ _gdk_x11_display_create_surface (GdkDisplay     *display,
 
   connect_frame_clock (surface);
 
-  gdk_surface_freeze_toplevel_updates (surface);
+  gdk_surface_freeze_updates (surface);
 
   if (parent)
     {